package com.javagi.controller;

import com.javagi.utils.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class RedisControl {

    @Autowired
    private RedisUtils redisUtils;

    @RequestMapping(value = "/setValue",method = RequestMethod.GET)
    public String setValue(){
        String key = "Hi";
        String value = "World";
        try{
            redisUtils.set(key,value);
        }catch (Exception e){
            e.printStackTrace();
            return "FAIL";
        }
        return "SUCCESS";
    }

    @RequestMapping(value = "/getValue",method = RequestMethod.GET)
    public String getValue(){
        String key = "Hi";
        return (String)redisUtils.get(key);
    }

}